package com.ftg.product.util;

import com.alibaba.fastjson.JSONObject;
import redis.clients.jedis.Jedis;

public class DealUserToken {
	

	public static TblStaffUtil parseUserToken(String token) throws Exception {
		Jedis jedis = null; 	
		TblStaffUtil staff = null;
		String jsonStaff = null;
		try {
			if(token == null) {
				return null;
			}
			String staffId = EncryptUtil.getInstance().AESdecode(token,EncryptUtil.DESKEY);
			jedis = JedisUtil.getJedis();
			jsonStaff = jedis.get(staffId+JedisUtil.USERINFOKEY);
			if(jsonStaff == null) {
				return null;
			}
			staff = (TblStaffUtil) JSONObject.parseObject(jsonStaff,TblStaffUtil.class);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(jedis != null) {
				jedis.close();
			}
		}
		return staff;
	}


}
